package info.heidao.ww2.controller;

import info.heidao.ww2.api.BigFunApi;
import info.heidao.ww2.api.common.CommonResp;
import info.heidao.ww2.api.resp.KanGongGuildLogFilterResp;
import info.heidao.ww2.api.resp.KanGongGuildLogResp;
import info.heidao.ww2.api.resp.KanGongGuildReportResp;
import info.heidao.ww2.framework.exception.BizException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: zhengheng
 * @Date: 2021-08-03 15:55
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/bifgun/api")
@Api(tags = "bigfun接口")
public class BigFunController {

    @Autowired
    private BigFunApi bigFunApi;

    @ApiOperation("成员列表")
    @GetMapping("/kan-gong-guild-log-filter")
    public CommonResp<KanGongGuildLogFilterResp> kanGongGuildLogFilter() {
        try {
            return bigFunApi.kanGongGuildLogFilter().get();
        } catch (Exception e) {
            throw new BizException("调用bigfun接口异常:" + e.getMessage());
        }
    }

    @ApiOperation("每日出刀情况")
    @GetMapping("/kan-gong-guild-report")
    public CommonResp<List<KanGongGuildReportResp>> kanGongGuildReport(@RequestParam(value = "date", required = false) String date) {
        try {
            return bigFunApi.kanGongGuildReport(date).get();
        } catch (Exception e) {
            throw new BizException("调用bigfun接口异常:" + e.getMessage());
        }
    }

    @ApiOperation("每日出刀详情列表")
    @GetMapping("/kan-gong-guild-log")
    public CommonResp<List<KanGongGuildLogResp>> kanGongGuildLog(@RequestParam(value = "date", required = false) String date,
                                                                 @RequestParam(value = "user_id", required = false) Long userId,
                                                                 @RequestParam(value = "page", required = false) Integer page,
                                                                 @RequestParam(value = "size", required = false) Integer size) {
        try {
            return bigFunApi.kanGongGuildLog(date, userId, page, size).get();
        } catch (Exception e) {
            throw new BizException("调用bigfun接口异常:" + e.getMessage());
        }
    }
}
